package edu.nanyang.dao;

import edu.nanyang.domain.ClassInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClassInfoDao {
    @Delete("delete from class_info where id=#{id}")
    int delete(int id);

    @Insert("insert into class_info(class_name,create_time) values(#{className},now())")
    int add(ClassInfo classInfo);

    @Update("update class_info set class_name=#{className},operate_time=now() where id=#{id}")
    int update(ClassInfo classInfo);

    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "className", column = "class_name"),
            @Result(property = "createTime", column = "create_time")
    })
    @Select("select * from academy_info where id=#{id}")
    ClassInfo getById(int id);

    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "className", column = "class_name"),
            @Result(property = "createTime", column = "create_time")
    })
    @Select("select * from academy_info")
    List<ClassInfo> findAll();

}
